import pymysql

if __name__ == '__main__':
    db = pymysql.connect( "192.168.0.242", "root", "Kc@123456", "helmet_operate_sit_test" )
    cursor = db.cursor()
    selectSql = 'SELECT ao.order_id , ao.agent_id FROM kc_agent_order ao'
    cursor.execute( selectSql )
    fetchall = cursor.fetchall()
    for table in fetchall:
        orderid = table[0]
        agentid = table[1]
        sqlupdate = 'update kc_order_info set contract_name = \'' + agentid + '\' WHERE order_id = \'' + orderid + '\''
        print(sqlupdate)
        cursor.execute(sqlupdate)
        db.commit()


